import React from "react"

import http from "@/api/helper/request"

import { IQueryListParams, IResponseItem, IResponseSummary } from "./types"

const useApi = () => {
	const { useState } = React
	const [loading, setLoading] = useState(false)

	async function generalHttp<T>(url: string, body: object | undefined, config: object = {}) {
		setLoading(true)
		let ret = await http.post<T>(url, body, config)
		setLoading(false)
		return ret
	}

	const getTableData = (body: IQueryListParams) =>
		generalHttp<Business.TableResourceType<IResponseItem, IResponseSummary>>("/report/proxyLoanBill/hist/listPage", body)

	// const proxyArtificialPatchAccountAddAuditDetail = (body?: IQueryItemDetailParams) =>
	// 	generalHttp<IResponseItemDetail>("/proxyArtificialPatchAccountAdd/auditDetail", body)

	return {
		loading,
		generalHttp,
		getTableData
	}
}

export default useApi
